package com.itheima.controller.backend;

import com.github.pagehelper.Page;
import com.itheima.Service.CheckGroupService;
import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.common.entity.Result;
import com.itheima.pojo.CheckGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController()
@RequestMapping("/checkgroup")
public class CheckGroupController {
@Autowired
    CheckGroupService checkGroupService;
@PostMapping("/add")
public Result addGroup(@RequestBody CheckGroup checkGroup, @RequestParam String checkitemIds){
    checkGroupService.addGroup(checkGroup,checkitemIds);
    return new Result(true,"添加检查组成功",null);
}
@GetMapping("deleteById")
    public Result deleteById(@RequestParam("id") Integer id){
    checkGroupService.deleteById(id);
    return new Result(true,"删除检查组成功",null);
}
@PostMapping("/edit")
    public Result edit(@RequestBody CheckGroup checkGroup,@RequestParam String checkitemIds){
    checkGroupService.edit(checkGroup,checkitemIds);
    return new Result(true,"修改检查组成功",null);
}
@PostMapping("findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
    Page<CheckGroup> page=checkGroupService.findPage(queryPageBean);
    return new PageResult(page.getTotal(),page.getResult());
}
}
